﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;

namespace WorkStation.Frameworks.Configuration
{
    public class ConfigurationInfoElement : ConfigurationElement
    {
        [ConfigurationProperty("name", IsRequired = true, IsKey = true)]
        public string ConfigurationName
        {
            get { return this["name"] as string; }
            set { this["name"] = value; }
        }

        [ConfigurationProperty("filePath", IsRequired = true)]
        public string ConfigurationFilePath
        {
            get { return this["filePath"] as string; }
            set { this["name"] = value; }
        }
    }

    public class ConfigurationInfoElementCollection : ConfigurationElementCollection
    {
        protected override ConfigurationElement CreateNewElement()
        {
            return new ConfigurationInfoElement();
        }

        protected override object GetElementKey(ConfigurationElement element)
        {
            return ((ConfigurationInfoElement)element).ConfigurationName;
        }

        public ConfigurationInfoElement this[string name]
        {
            get 
            { 
                return BaseGet(name) as ConfigurationInfoElement; 
            }
        }

        public ConfigurationInfoElement this[int index]
        {
            get { return BaseGet(index) as ConfigurationInfoElement; }
        }

        protected override string ElementName
        {
            get
            {
                return "add";
            }
        }

        public override ConfigurationElementCollectionType CollectionType
        {
            get
            {
                return ConfigurationElementCollectionType.BasicMap;
            }
        }
    }
}
